#include "board.h"

Board::Board(QObject *parent) : QObject(parent)
{
    for(int i = 0;i < 10; i++)
    {
        for(int j = 0;j < 10;j++)
            this->minePos[i][j] = false;
    }
    QRandomGenerator random;
    random.seed((unsigned int)time(NULL));
    int i = 0;
    bool flag = false;
    do
    {
        flag = false;
        int x = random.generate()%10;
        int y = random.generate()%10;
        if(i != 0)
        {
            for(int n = 0;n < i;n++)
            {
                if(m_hideBoard[n].first == x && m_hideBoard[n].second == y)
                {
                    flag = true;
                    break;
                }
            }
        }
        if(flag == true)
        {
            continue;
        }
        else
        {
            QPair<int,int> pair;
            pair.first=x;
            pair.second=y;
            m_hideBoard.push_back(pair);
            this->minePos[x][y] =true;
            i++;
        }
    }while(i<10);
}


QPair<int,int> Board::getPosition(int n)
{
    return this->m_hideBoard[n];
}

bool Board::isMine(int x, int y)
{
    return this->minePos[x][y];
}
